package com.lej.dataservice.club.bean.userinfo

import android.os.Parcelable
import com.lej.core.common.*
import com.lej.core.provider.resourceProvider
import com.lej.core.utils.extention.safe
import kotlinx.parcelize.Parcelize


data class UperInfo(
    val age: String,
    val avatar: String,
    val city: String,
    val courses: String,
    val distance: String,
    //1男0女
    val gender: Int,
    val graduate: String,
    //0暂未认证 1 在校 2毕业
    val graduatestatus: Int,
    val nick: String,
    val occupation: String,
    val photos: List<UperPhoto>,
    val qa: List<UperQa>,
    //0 没有星标 1星标
    val star_status: String,
    val uid: String,


    /**pk 用户信息使用的字段*/
    //真人认证状态 参考之前的状态约定值  0未活体验证 1已经活体验证
    @CheckStatus
    val base_photo_status: Int,
    val college: String,
    /**在读[AT_SCHOOL]  毕业 [UN_AT_SCHOOL]*/
    @CheckStatus
    val graduate_status: Int,
    /**证件状态 参考之前的状态约定值 暂未认证  0 未上传证件照 1被拒绝 2审核通过 3待审核  [CheckStatus] */
    @CheckStatus
    val paper_status: Int,
    val rankings: List<Ranking>,
    //0 没有星标 1星标
    val star: String?,

    val slide_like_status: String?,//是否滑动喜欢0:未知,1:不喜欢,2:喜欢
    val slidebar_status: String?,//爱心是否被点击,0:未点击,1:已点击
    val svip: String,

    ///1.2.0
    //兴趣爱好列表
    var hobbies: MutableList<UserTagBean>,
    //收入金额
    var income: String?,
    ///任务数
    var tasks: String?,
    ///进行中任务
    var tasks_processing: List<UserTaskBean>?,
) {
    val location: String? = ""

    //自我介绍
    val whatsup: String? = ""
        get() = field.safe()

    fun isBoy() = gender == SEX_BOY
    fun graduateDisplay() = graduate.safe(resourceProvider.getGraduateStatusStr(graduate_status))

    fun showAgeStr() = if (gender > 0) age else ""
    fun authReal() = base_photo_status == CHECK_PASS
    fun authSchool() = paper_status == CHECK_PASS
    fun vipInt() = svip.toIntOrNull().safe(VIP0)
    fun shareStr() = "分享${nick}的个人资料"
    fun hobbiesStr() = hobbies.joinToString(" ") { it.tag_name }
    fun noHobbies() = hobbies.isNullOrEmpty()
    fun hasIncome()= !income.isNullOrEmpty()
    fun hasTasks()= !tasks.isNullOrEmpty()

    fun barIsExpand() = slide_like_status == "2" || slidebar_status == "1"
}

data class UperPhoto(
    val photoid: String = "",
    val photourl: String,
    //0图片 1视频
    val type: String = "0"
)

data class UperQa(
    val avatar: String,
    val content: String,
    val type: String
)

data class ResJoinRanking(
    val rankings: List<Ranking>
)

@Parcelize
data class Ranking(
    val cardid: String = "",
    var cardname: String,
    var cardsubname: String? = null,
    /**[SEX_BOY]*/
    val gender: String,
    val index: Int = 0,
    val tagid: String,

    ///能否battle  发起battle用  0 不在同一榜单 1在同一榜单
    val can_battle: Int = 0
) : Parcelable {
    fun canBattle() = can_battle == 1
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as Ranking

        if (cardid != other.cardid) return false
        if (cardname != other.cardname) return false
        if (cardsubname != other.cardsubname) return false
        if (gender != other.gender) return false
        if (index != other.index) return false
        if (tagid != other.tagid) return false

        return true
    }

    override fun hashCode(): Int {
        var result = cardid.hashCode()
        result = 31 * result + cardname.hashCode()
        result = 31 * result + gender.hashCode()
        result = 31 * result + index
        result = 31 * result + tagid.hashCode()
        return result
    }
}